package com.cfpl.admin_service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cfpl.admin_service.VO.VegEnvMonitoring;
import com.cfpl.admin_service.service.EnvironmentalMonitoringService;
import com.cfpl.project_common.enums.CodeEnum;
import com.cfpl.project_common.exception.BusException;
import com.cfpl.project_common.pojo.EnvironmentalMonitoring;
import com.cfpl.admin_service.mapper.EnvironmentalMonitoringMapper;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 14720
* @description 针对表【environmental_monitoring(环境监测数据表)】的数据库操作Service实现
* @createDate 2023-10-10 11:09:53
*/
@Service
public class EnvironmentalMonitoringServiceImpl extends ServiceImpl<EnvironmentalMonitoringMapper, EnvironmentalMonitoring>
    implements EnvironmentalMonitoringService {
    @Autowired
    private EnvironmentalMonitoringMapper envMonitoringMapper;
    /**
     * 分页查询环境检测数据
     * @param currentPage 当前页
     * @param pageSize 每条页数
     * @param condition  分页对象
     * @return 分页查询环境检测数据
     */
    @Override
    public Page<EnvironmentalMonitoring> queryPage(int currentPage, int pageSize, String condition) {
        LambdaQueryWrapper<EnvironmentalMonitoring> queryWrapper = new LambdaQueryWrapper<>();
        return envMonitoringMapper.selectPage(new Page<>(currentPage,pageSize),queryWrapper);
    }
    /**
     * 添加环境监测数据
     * @param envMonitoring 环境监测数据
     */
    @Override
    public void addEnvMonitoring(EnvironmentalMonitoring envMonitoring) {
        envMonitoringMapper.insert(envMonitoring);
    }
    /**
     * 根据id查询环境检测数据
     *
     * @param Id 环境检测 id
     * @return 环境检测数据
     */
    @Override
    public EnvironmentalMonitoring queryEnvMonitoringById(Long Id) {
        return envMonitoringMapper.selectById(Id);
    }
    /**
     * 根据 ID删除环境监测数据
     * @param Id 环境监测id
     */
    @Override
    public void removeEnvMonitoringById(Long Id) {
        envMonitoringMapper.deleteById(Id);
    }
    /**
     * 更新一条环境监测数据
     * @param envMonitoring  环境监测数据
     */
    @Override
    public void updateEnvMonitoring(EnvironmentalMonitoring envMonitoring) {
        envMonitoringMapper.updateById(envMonitoring);
    }
    /**
     * 批量删除环境监测数据
     * @param Ids  环境监测ID列表
     */
    @Override
    public void deleteBatchByIds(List<Long> Ids) {
        if (Ids == null || Ids.size() < 1) {
            throw  new BusException(CodeEnum.PARAMETER_ERROR);
        }
        envMonitoringMapper.deleteBatchIds(Ids);
    }


}




